<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./echarts.js"></script>
    <style>
        #main{
            border: 1px solid skyblue;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div id="main" style="width: 600px; height: 400px;"></div>
    <script>
        let myChart = echarts.init(document.querySelector('#main'))
        let option = {
            title:{
                text:'性别,年龄段堆积柱状图'
            },
            tooltip:{
                trigger: 'axis',
                axisPointer: {  //设置坐标轴指示器，坐标轴触发有效
                    type: 'shadow'  //设置坐标轴默认为直线，可选为:'line'|'shadow'

                },
            },
            legend:{
                data:['男性','女性']
            },
            yAxis:{},
            xAxis:[
                {
                    data:['20~29','30~39','40~49']
                }
            ],
            series:[
                {
                    name:'男性',
                    type:'bar',
                    color:'skyblue',
                    stack:'总量',
                    data:[4,0,1]
                },
                {
                    name:'女性',
                    color:'#32c27c',
                    type:'bar',
                    stack:'总量',
                    data:[7,3,0]
                }
            
            ],
        };
        myChart.setOption(option)
    </script>
</body>
</html>